package jmine.tec.persist.schema.impl.elements.type;

/**
 * Implementação de valor permitido para valores do tipo Integer
 * 
 * @author lundberg
 */
public class IntegerAllowedValue implements AllowedValue {

    private final Integer allowedValue;

    private final String description;

    /**
     * Construtor
     * 
     * @param value valor permitido
     * @param description description
     */
    public IntegerAllowedValue(Integer value, String description) {
        this.allowedValue = value;
        this.description = description;
    }

    /**
     * {@inheritDoc}
     */
    public int compareInteger(Integer value) {
        return value.compareTo(this.allowedValue);
    }

    /**
     * {@inheritDoc}
     */
    public int compareString(String value) {
        return value.compareTo(value.toString());
    }

    /**
     * {@inheritDoc}
     */
    public String getValue() {
        return this.allowedValue.toString();
    }

    /**
     * {@inheritDoc}
     */
    public int compareTo(AllowedValue o) {
        return o.compareInteger(this.allowedValue);
    }

    /**
     * {@inheritDoc}
     */
    public String getDescription() {
        return this.description;
    }
}
